package org.myh.excel.example;



import org.myh.excel.FieldSort;
import org.myh.excel.anno.Sort;

import java.util.Objects;

/**
 * ClassName: ExcelDto
 * Description:  一个测试用例
 * date: 2024/3/24 12:01
 *
 * @author Yu Han
 * @since JDK 1.8
 * 基于注解的形式还未实现，与field字段类似
 */
@Sort({"buildName", "areaCode", "num", "floorNum", "bunk", "cost", "roomType"})
public class ExcelDto implements FieldSort {

    private String buildName;
    private Integer areaCode;
    private Integer num;
    private Integer floorNum;
    private Integer bunk;
    private Double cost;
    private String roomType;

    private static final String[] fields = new String[]{"buildName", "areaCode", "num", "floorNum", "bunk", "cost", "roomType"};

    /**
     * 返回对应excel的读取顺序
     *
     * @return
     */
    @Override
    public String[] sortField() {
        return fields;
    }

    /**
     * 必须实现Object的clone方法，默认返回此实例的一个clone对象
     *
     * @return
     * @throws CloneNotSupportedException
     */
    @Override
    public ExcelDto clone() throws CloneNotSupportedException {
        return new ExcelDto();
    }

    public String getBuildName() {
        return buildName;
    }

    public void setBuildName(String buildName) {
        this.buildName = buildName;
    }

    public Integer getAreaCode() {
        return areaCode;
    }

    public void setAreaCode(Integer areaCode) {
        this.areaCode = areaCode;
    }

    public Integer getNum() {
        return num;
    }

    public void setNum(Integer num) {
        this.num = num;
    }

    public Integer getFloorNum() {
        return floorNum;
    }

    public void setFloorNum(Integer floorNum) {
        this.floorNum = floorNum;
    }

    public Integer getBunk() {
        return bunk;
    }

    public void setBunk(Integer bunk) {
        this.bunk = bunk;
    }

    public Double getCost() {
        return cost;
    }

    public void setCost(Double cost) {
        this.cost = cost;
    }

    public String getRoomType() {
        return roomType;
    }

    public void setRoomType(String roomType) {
        this.roomType = roomType;
    }

    public static String[] getFields() {
        return fields;
    }

    @Override
    public String toString() {
        return "ExcelDto{" +
                "buildName='" + buildName + '\'' +
                ", areaCode=" + areaCode +
                ", num=" + num +
                ", floorNum=" + floorNum +
                ", bunk=" + bunk +
                ", cost=" + cost +
                ", roomType='" + roomType + '\'' +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }

        if (o == null || getClass() != o.getClass()){
            return false;
        }

        ExcelDto excelDto = (ExcelDto) o;
        return Objects.equals(buildName, excelDto.buildName) &&
                Objects.equals(areaCode, excelDto.areaCode) &&
                Objects.equals(num, excelDto.num) &&
                Objects.equals(floorNum, excelDto.floorNum) &&
                Objects.equals(bunk, excelDto.bunk) &&
                Objects.equals(cost, excelDto.cost) &&
                Objects.equals(roomType, excelDto.roomType);
    }

    @Override
    public int hashCode() {
        return Objects.hash(buildName, areaCode, num, floorNum, bunk, cost, roomType);
    }
}
